#!/usr/bin/ruby

    
def print_form
    t = Time.now()
    default_start_year  = t.year
    default_start_month = t.month
    default_start_day   = t.mday
    default_start_hour  = 0
    default_start_min   = 0
    default_end_hour  = 0
    default_end_min   = 0

    default_start_month_desc = t.strftime("%b")
    default_start_day_desc   = t.strftime("%a %d")
    
    other_year_options = [2012, 2013].map \
        {|y| "<option value=\"#{y}\">#{y}</option>"}.join("\n")

    year_select = " 
    <select name=\"start_year\">
        <option value=\"#{default_start_year}\" selected=\"selected\"> 
            [ #{default_start_year} ] </option>
        #{other_year_options}
    </select>"

    month_select = "
    <select name=\"start_month\">
        <option value=\"#{default_start_month}\" selected=\"selected\"> 
            [ #{default_start_month_desc} ] </option>
        <option value=\"1\">Jan</option>
        <option value=\"2\">Feb</option>
        <option value=\"3\">Mar</option>
        <option value=\"4\">Apr</option>
        <option value=\"5\">May</option>
        <option value=\"6\">Jun</option>
        <option value=\"7\">Jul</option>
        <option value=\"8\">Aug</option>
        <option value=\"9\">Sep</option>
        <option value=\"10\">Oct</option>
        <option value=\"11\">Nov</option>
        <option value=\"12\">Dec</option>
    </select>
    "

    start_day_select = "
    <select name=\"start_day\">
    <option value=\"#{default_start_day}\" selected=\"selected\"> 
        [ #{default_start_day_desc} ] </option>
    <option value=\"1\">1</option>
    <option value=\"2\">2</option>
    <option value=\"3\">3</option>
    <option value=\"4\">4</option>
    <option value=\"5\">5</option>
    <option value=\"6\">6</option>
    <option value=\"7\">7</option>
    <option value=\"8\">8</option>
    <option value=\"9\">9</option>
    <option value=\"10\">10</option>
    <option value=\"11\">11</option>
    <option value=\"12\">12</option>
    <option value=\"13\">13</option>
    <option value=\"14\">14</option>
    <option value=\"15\">15</option>
    <option value=\"16\">16</option>
    <option value=\"17\">17</option>
    <option value=\"18\">18</option>
    <option value=\"19\">19</option>
    <option value=\"20\">20</option>
    <option value=\"21\">21</option>
    <option value=\"22\">22</option>
    <option value=\"23\">23</option>
    <option value=\"24\">24</option>
    <option value=\"25\">25</option>
    <option value=\"26\">26</option>
    <option value=\"27\">27</option>
    <option value=\"28\">28</option>
    <option value=\"29\">29</option>
    <option value=\"30\">30</option>
    <option value=\"31\">31</option>
    </select>
    "

    start_hr_select = "
    <select name=\"start_hour\">
    <option value=\"#{default_start_hour}\" selected=\"selected\"> 
        [ #{default_start_hour} ] </option>
    <option value=\"0\">12am</option>
    <option value=\"1\">1am</option>
    <option value=\"2\">2am</option>
    <option value=\"3\">3am</option>
    <option value=\"4\">4am</option>
    <option value=\"5\">5am</option>
    <option value=\"6\">6am</option>
    <option value=\"7\">7am</option>
    <option value=\"8\">8am</option>
    <option value=\"9\">9am</option>
    <option value=\"10\">10am</option>
    <option value=\"11\">11am</option>
    <option value=\"12\">12am</option>
    <option value=\"13\">1pm</option>
    <option value=\"14\">2pm</option>
    <option value=\"15\">3pm</option>
    <option value=\"16\">4pm</option>
    <option value=\"17\">5pm</option>
    <option value=\"18\">6pm</option>
    <option value=\"19\">7pm</option>
    <option value=\"20\">8pm</option>
    <option value=\"21\">9pm</option>
    <option value=\"22\">10pm</option>
    <option value=\"23\">11pm</option>
    </select>
    "
    
    start_min_select = "
    <select name=\"start_min\">
    <option value=\"#{default_start_min}\" selected=\"selected\"> 
        [ #{default_start_min} ] </option>
    <option value=\"0\">0</option>
    <option value=\"10\">10</option>
    <option value=\"20\">20</option>
    <option value=\"30\">30</option>
    <option value=\"40\">40</option>
    <option value=\"50\">50</option>
    </select>
    "

    end_day_select = "
    <select name=\"same_day\">
    <option value=\"True\" selected=\"selected\"> end on same day</option>
    <option value=\"False\">end on next day</option>
    </select>
    "

    end_hr_select = "
    <select name=\"end_hour\">
    <option value=\"#{default_end_hour}\" selected=\"selected\"> 
        [ #{default_end_hour} ] </option>
    <option value=\"0\">12am</option>
    <option value=\"1\">1am</option>
    <option value=\"2\">2am</option>
    <option value=\"3\">3am</option>
    <option value=\"4\">4am</option>
    <option value=\"5\">5am</option>
    <option value=\"6\">6am</option>
    <option value=\"7\">7am</option>
    <option value=\"8\">8am</option>
    <option value=\"9\">9am</option>
    <option value=\"10\">10am</option>
    <option value=\"11\">11am</option>
    <option value=\"12\">12am</option>
    <option value=\"13\">1pm</option>
    <option value=\"14\">2pm</option>
    <option value=\"15\">3pm</option>
    <option value=\"16\">4pm</option>
    <option value=\"17\">5pm</option>
    <option value=\"18\">6pm</option>
    <option value=\"19\">7pm</option>
    <option value=\"20\">8pm</option>
    <option value=\"21\">9pm</option>
    <option value=\"22\">10pm</option>
    <option value=\"23\">11pm</option>
    </select>
    "

    end_min_select = "
    <select name=\"end_min\">
    <option value=\"#{default_end_min}\" selected=\"selected\"> 
        [ #{default_end_min} ] </option>
    <option value=\"0\">0</option>
    <option value=\"10\">10</option>
    <option value=\"20\">20</option>
    <option value=\"30\">30</option>
    <option value=\"40\">40</option>
    <option value=\"50\">50</option>
    </select>
    "

    puts HTML_HEAD + \
"
<center>
<form>
    <table border=\"1\"> <tr> 
    <td>year</td>
    <td>month</td>
    <td>day</td>
    </tr> <tr>
    <td>#{year_select}</td>
    <td>#{month_select}</td>
    <td>#{start_day_select}</td>
    </tr></table>
    
    <br/>#{end_day_select}<br/><br/>

    <table border=\"1\"><tr>
    <td></td>
    <td>hour</td>
    <td>minute</td>
    </tr><tr>
    <td>start time:</td>
    <td>#{start_hr_select}</td>
    <td>#{start_min_select}</td>
    </tr><tr>
    <td>end time:</td>
    <td>#{end_hr_select}</td>
    <td>#{end_min_select}</td>
    </tr></table>


    <br/>
    <input type=\"submit\" value=\"Submit\" />
</form>
</center>" + HTML_END

end
